package com.lh.controller;

import com.alibaba.fastjson.JSONObject;
import com.lh.entity.table.DeadlineNode;
import com.lh.entity.table.ProcessNode;
import com.lh.entity.table.TicketProblemInfo;
import com.lh.service.TicketProblemInfoService;
import com.lh.utils.Answer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/ticketProblem")
public class TicketProblemInfoController {

    @Autowired
    private TicketProblemInfoService ticketProblemInfoService;

    @RequestMapping("/addTicketProblemInfo")
    public Answer<Object> addTicketProblemInfo(@RequestBody TicketProblemInfo ticketProblemInfo) {
        return  ticketProblemInfoService.addTicketProblemInfo(ticketProblemInfo);
    }

    @RequestMapping("/addTicketProblemInfoList")
    public Answer<Object> addTicketProblemInfoList(@RequestBody JSONObject reqJson) {
        return  ticketProblemInfoService.addTicketProblemInfoList(reqJson);
    }

    @RequestMapping("/updateTicketProblemInfo")
    public Answer<Object> updateTicketProblemInfo(@RequestBody TicketProblemInfo ticketProblemInfo) {
        return  ticketProblemInfoService.updateTicketProblemInfo(ticketProblemInfo);
    }

    @RequestMapping("/deleteTicketProblemInfo")
    public Answer<Object> deleteTicketProblemInfo(@RequestBody TicketProblemInfo ticketProblemInfo) {
        return  ticketProblemInfoService.deleteTicketProblemInfo(ticketProblemInfo);
    }

    @RequestMapping("/selectTicketProblemInfo")
    public Answer<Object> selectTicketProblemInfo(@RequestBody TicketProblemInfo ticketProblemInfo) {
        return  ticketProblemInfoService.selectTicketProblemInfo(ticketProblemInfo);
    }

    @RequestMapping("/selectTicketProblemInfoList")
    public Answer<Object> selectTicketProblemInfoList(@RequestBody JSONObject reqJson) {
        return  ticketProblemInfoService.selectTicketProblemInfoList(reqJson);
    }

    @RequestMapping("/selectTicketProblemInfoPage")
    public Answer<Object> selectTicketProblemInfoPage(@RequestBody JSONObject reqJson) {
        return ticketProblemInfoService.selectTicketProblemInfoPage(reqJson);
    }

    /**
     * 驳回工单
     */
    @RequestMapping("/processBack")
    public Answer<Object> processBack(@RequestBody TicketProblemInfo ticketProblemInfo) {
        return ticketProblemInfoService.processBack(ticketProblemInfo);
    }

    /**
     * 处理工单
     */
    @RequestMapping("/processIssuance")
    public Answer<Object> processIssuance(@RequestBody JSONObject reqJson) {
        return  ticketProblemInfoService.processIssuance(reqJson);
    }

    /**
     * 结束工单
     */
    @RequestMapping("/processEnd")
    public Answer<Object> processEnd(@RequestBody JSONObject reqJson) {
        return  ticketProblemInfoService.processEnd(reqJson);
    }


    /**
     *  查询工单流程
     */
    @RequestMapping("/queryNodeList")
    public Answer<Object> queryNodeList(@RequestBody JSONObject reqJson) {
        return ticketProblemInfoService.queryNodeList(reqJson);
    }

    /**
     *  更新工单流程
     */
    @RequestMapping("/updateNodeList")
    public Answer<Object> updateNodeList(@RequestBody ProcessNode processNode) {
        return ticketProblemInfoService.updateNodeList(processNode);
    }

    /**
     * 上传附件
     */
    @RequestMapping(value="/uploadFile",method= RequestMethod.POST,produces="application/json")
    public Answer<Object> uploadFile(HttpServletRequest request){
        return ticketProblemInfoService.uploadFile(request);
    }

    /**
     * 导出工单模板
     */
    @PostMapping("/downTicketProblemExcelData")
    public void downTicketProblemExcelData(HttpServletResponse response, @RequestBody JSONObject reqJson) {
        ticketProblemInfoService.downTicketProblemExcelData(response,reqJson);
    }

    /**
     * 导入工单
     */
    @PostMapping("/importTicketProblemInfo")
    public Answer<Object> importTicketProblemInfo(@RequestParam("file") MultipartFile file) {
        return ticketProblemInfoService.importTicketProblemInfo(file);
    }

    /**
     *  修改时限
     */
    @RequestMapping("/updateDeadlineNode")
    public Answer<Object> updateDeadlineNode(@RequestBody DeadlineNode deadlineNode) {
        return ticketProblemInfoService.updateDeadlineNode(deadlineNode);
    }

}